﻿@using SH = EMoney.IStock.Client.Framework.StringHelper;

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>我的记录</title>
    <link rel="stylesheet" type="text/css" href="@SH.GetStaticFile("IStockClientStatic/cpyx/css/main.css")" id="linkcss" />
    <script src="http://static.emoney.cn/js/libs/jquery.min.1.8.3.js" type="text/javascript"></script>
    <style type="text/css">
        .jscroll-c{top: 0px; z-index: 9999; zoom: 1; position: relative;overflow:hidden;}
        .jscroll-e{height: 100%; top: 0px; right: 0; -moz-user-select: none; position: absolute; overflow: hidden; z-index: 10000; background: url(http://static.emoney.cn/www/emfastock/img/scrollbarblock2.gif) -33px 0 repeat-y;}
        .jscroll-u{position: absolute; top: 0px; width: 100%; left: 0; overflow: hidden; background: trasparent;}
        .jscroll-h{position: absolute;left: 0px; -moz-user-select: none; border: 0; overflow: hidden; text-align: center;}
        .jscroll-bart{width: 11px; height: 6px; background: url(http://static.emoney.cn/www/emfastock/img/scrollbarblock2.gif) no-repeat -1px -1px; overflow: hidden;}
        .jscroll-h-i{width: 13px; height: 5px; background: url(http://static.emoney.cn/www/emfastock/img/scrollbarblock2.gif) repeat-y -16px top; overflow: hidden;}
        .jscroll-h-s{width: 13px; height: 100%; background: url(http://static.emoney.cn/www/emfastock/img/scrollbarblock2.gif) no-repeat -52px center; overflow: hidden;}
        .jscroll-barb{width: 11px; height: 6px; background: url(http://static.emoney.cn/www/emfastock/img/scrollbarblock2.gif) no-repeat -1px -10px; overflow: hidden;}
        .jscroll-d{position: absolute; bottom: 0px; width: 100%; left: 0; overflow: hidden; background: trasparent;}
        .scroll-pane{ margin-left:5px;}
    </style>
</head>
<body>
    <div class="main">
        <div id="navmenu" style="text-align:center;padding-top:5px;padding-bottom:4px;">
           <ul><li class="on" flag="operate"><div class="L"><b>最近操作</b></div></li><li flag="record"><div class="R"><b>历史战绩</b></div></li></ul>
        </div>
        <div class="add_k">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" id="tableOperate">
                <tr>
                    <th align="center" style="width: 20%;" class="cwhite">游戏时间</th>
                    <th align="center" style="width: 30%;" class="cwhite">股票</th>
                    <th align="center" style="width: 30%;" class="cwhite">K线时间</th>
                    <th align="center" style="width: 20%;" class="cwhite">收益率</th>
                </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" id="tableRecord" style="display:none;">
                <tr>
                    <th align="center" style="width: 20%;" class="cwhite">统计时间</th>
                    <th align="center" style="width: 30%;" class="cwhite">周收益率</th>
                    <th align="center" style="width: 30%;" class="cwhite">周排名</th>
                    <th align="center" style="width: 20%;" class="cwhite">荣誉</th>
                </tr>
            </table>
            <div id="scrollBox1" class="scrollBox" scrollflag style="height: 210px;">
                <table width="100%" id="" border="0" cellspacing="0" cellpadding="0">
                    <thead style="height: 0px; display: none;">
                        <tr>
                            <th align="center" style="width: 20%;" class="cwhite">游戏时间</th>
                            <th align="center" style="width: 30%;" class="cwhite">股票</th>
                            <th align="center" style="width: 30%;" class="cwhite">K线时间</th>
                            <th align="center" style="width: 20%;" class="cwhite">收益率</th>
                        </tr>
                    </thead>
                    <tbody id="wdjlbody"></tbody>
                </table>
            </div>
        </div>
    </div>
    <input type="hidden" id="hidUserID" value="@ViewBag.UserID" />
</body>
    <script src="@SH.GetStaticFile("IStockClientStatic/js/EMWEBUIscrollBar.js")" type="text/javascript"></script>
    <script src="@SH.GetStaticFile("IStockClientStatic/js/common.js")" type="text/javascript"></script>
    <script src="@SH.GetStaticFile("IStockClientStatic/js/istockfunc.js")" type="text/javascript"></script>
</html>
<script type="text/javascript">
    var www = "@Url.Content("~/")", userid = $("#hidUserID").val(), allcode = "";

    $(document).ready(function () {
        $("#scrollBox1").height(210);

        $(".scrollBox").jscroll({ W: "8px", IW: "8px", CurrT: 0, Bar: { Pos: "up" }, Btn: { btn: false }, Fn: function () { } }).hover(function (e) {
            var thisbx = $(this), scrlbr = $(this).find(".jscroll-e");
            if (!scrlbr.hasClass("non")) {
                scrlbr.addClass("mon").stop(true, true, false).show();
            }
        }, function (e) {
            var thisbx = $(this), scrlbr = $(this).find(".jscroll-e");
            if (!scrlbr.hasClass("non")) {
                scrlbr.removeClass("mon");
                if (scrlbr.hasClass("vxdrag")) { } else {
                    //scrlbr.fadeOut("slow");
                }
            }
        });

        $("#navmenu ul li").click(function () {
            var flag = $(this).attr("flag");
            
            switch (flag) {
                case "operate":
                    $("#tableOperate").show();
                    $("#tableRecord").hide();
                    break;
                case "record":
                    $("#tableOperate").hide();
                    $("#tableRecord").show();
                    break;
                default:
                    break;
            }

            $(this).addClass("on").siblings().removeClass("on");

            getWdjl(flag);
        });

        $("#navmenu ul li")[0].click();
    });

    function formatSecucode(secucode)
    {
        if (secucode != "" && secucode.length == 7) {
            return secucode.substr(1, 6);
        }
        else {
            return secucode;
        }
    }

    function formatDate(dt) {
        if (dt != undefined && dt != "" && dt.length == 8) {
            return dt.substr(0, 4) + "." + dt.substr(4, 2) + "." + dt.substr(6, 2);
        }
        else {
            return dt;
        }
    }

    function getWdjl(flag)
    {
        if (userid == "0") {
            switch (flag) {
                case "operate":
                    var result = ISTOCK_FUNC_GUESTRESULT();

                    if (result == undefined || result == "") {
                        $("#wdjlbody").html("<tr><td colspan='4' align='center' style='color:grey;'><div style='line-height:266px;'>暂无记录<div></td></tr>");
                    }
                    else {
                        showResult(result);
                    }
                    break;
                case "record":
                    $("#wdjlbody").html("<tr><td colspan='4' align='center' style='color:grey;'><div style='line-height:266px;'>暂无记录<div></td></tr>");
                    break;
                default:
                    break;
            }            
        }
        else {
            $.ajax({
                type: "post",
                url: www + "cpyx/result",
                data: { flag:flag},
                datatype: "text",
                success: function (data) {
                    if (data != "") {
                        showResult(data,flag);
                    }
                    else {
                        $("#wdjlbody").html("<tr><td colspan='4' align='center' style='color:grey;'><div style='line-height:266px;'>暂无记录<div></td></tr>");
                    }
                },
                beforeSend: function () {
                    $("#wdjlbody").html("<tr><td colspan='4' align='center' style='color:grey;'><div style='line-height:266px;'>数据加载中...<div></td></tr>");
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                }
            });
        }
    }

    function showResult(data,flag)
    {
        var obj = eval('(' + data + ')');

        if (obj != null && obj.length > 0) {
            var html = "", award = "", awardclass = "";

            $.each(obj, function (i) {
                switch (flag) {
                    case "operate":
                        html += "<tr>";
                        html += "<td align=\"center\" style=\"width:20%;\" class=\"cyellow\">" + parseDate(obj[i].RecDateTime) + "</td>";
                        html += "<td align=\"center\" style=\"width:30%;\" class=\"cyellow\"><span class='secu' code=\"" + obj[i].SecuCode + "\">" + ISTOCK_FUNC_GETSECUABBR(obj[i].SecuCode) + " " + formatSecucode(obj[i].SecuCode) + "</span></td>";
                        html += "<td align=\"center\" style=\"width:30%;\" class=\"cwhite\">" + formatDate(obj[i].BeginDateTime) + "~" + formatDate(obj[i].EndDateTime) + "</td>";
                        html += "<td align=\"center\" style=\"width:20%;\" class=\"" + formatColor(obj[i].Profit, "cred", "cgreen", "cwhite") + "\">" + formatFloat(obj[i].Profit, 2) + "%</td>";
                        html += "</tr>";
                        break;
                    case "record":
                        html += "<tr>";
                        html += "<td align=\"center\" style=\"width:20%;\" class=\"cwhite\">" + formatDate(obj[i].WeekEndDate) + "</td>";
                        html += "<td align=\"center\" style=\"width:30%;\" class=\"" + formatColor(obj[i].Profit, "cred", "cgreen", "cwhite") + "\">" + formatFloat(obj[i].Profit, 2) + "%</td>";
                        html += "<td align=\"center\" style=\"width:30%;\" class=\"cwhite\">" + obj[i].Idx + "</td>";

                        if (obj[i].Idx <= 50) {
                            switch (obj[i].Idx) {
                                case 1:
                                    award = "鹰眼监控策略包";
                                    break;
                                case 2:
                                    award = "超跌反弹策略包";
                                    break;
                                case 3:
                                    award = "重大利好策略包";
                                    break;
                                default:
                                    award = "20i豆";
                                    break;
                            }

                            awardclass = "cyellow";
                        }
                        else {
                            award = "--";
                            awardclass = "cwhite";
                        }

                        html += "<td align=\"center\" style=\"width:20%;\" class=\"" + awardclass + "\">" + award + "</td>";
                        html += "</tr>";
                        break;
                    default:
                        break;
                }                
            });

            if (html != "") {
                $("#wdjlbody").html(html);
                ReSetScroll();
            }
        }
    }
</script>